//
//  RootTabBarController.m
//  王宇先_09
//
//  Created by wyx on 16/3/21.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "RootTabBarController.h"
#import "ViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "NaviOfFirstViewController.h"
#import "NaviOfSecondViewController.h"
#import "NaviOfThirdViewController.h"

@interface RootTabBarController ()

@end

@implementation RootTabBarController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        
        // 设置root的viewControllers属性.
        self.viewControllers = [self createRootOfVCs];
        
    }
    
    return self;
}
- (NSArray<UIViewController *> *)createRootOfVCs {
    NSMutableArray *arrOfVCs = [NSMutableArray array];
    //第一个 Item
    ViewController *vc1 = [[ViewController alloc] init];
    
    NaviOfFirstViewController *navi1 = [[NaviOfFirstViewController alloc] initWithRootViewController:vc1];
    
    [arrOfVCs addObject:navi1];
    [vc1 release];
    [navi1 release];
    // 设置item
    navi1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"First" image:[UIImage imageNamed:@"iconfont-quanyi"] tag:100];
    //第二个 Item
    SecondViewController *vc2 = [[SecondViewController alloc] init];
    
    NaviOfSecondViewController *navi2 = [[NaviOfSecondViewController alloc] initWithRootViewController:vc2];
    
    [arrOfVCs addObject:navi2];
    [vc2 release];
    [navi2 release];
    // 设置item
    navi2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Second" image:[UIImage imageNamed:@"iconfont-quaner"] tag:200];
    //第三个 Item
    ThirdViewController *vc3 = [[ThirdViewController alloc] init];
    
    NaviOfThirdViewController *navi3 = [[NaviOfThirdViewController alloc] initWithRootViewController:vc3];
    
    [arrOfVCs addObject:navi3];
    [vc3 release];
    [navi3 release];
    // 设置item
    navi3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Third" image:[UIImage imageNamed:@"iconfont-quansan"] tag:300];
    
    
    
    
    return arrOfVCs;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
